import { createApp } from 'vue';

import axios from "axios";
import VueAxios from "vue-axios";

import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css';

import App from './App.vue';
// import router from './router/index.js';
import router from './router';
// import store from './store/index.js';
import store from './store';

const app = createApp(App);

axios.defaults.baseURL = '/api' ;

axios.interceptors.request.use(
    cfg => { 
        console.log(cfg); 
        let token = sessionStorage.getItem( 'authorization' );
        if( token ) {
            cfg.headers.authorization = token ;
        }
        return cfg; 
    },
    err => { console.log( err ) ; return Promise.reject( err ); }
);

app.use( VueAxios , axios );

app.use( ElementPlus );
app.use( store );
app.use( router );
app.mount('#app');
